package com.jiyoukeji.template.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.jdbc.Null;

/**
 * @Author: 李培洋
 * @Date: 2024/11/20 23:25
 * @Description: 返回结果处理类
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Result<T> {
    private String msg;
    private int code;
    private T data;

    public static <E> Result<E> success(E data) {
        return new Result<E>("操作成功", 200, data);
    }

    public static <E> Result<E> success(String msg, E data) {
        return new Result<E>(msg, 200, data);
    }

    public static Result<Null> success() {
        return new Result<Null>("操作成功", 200, null);
    }

    public static Result<Null> fail(String message) {
        return new Result<Null>(message, 400, null);
    }
}
